Class NewsControllerTest

java.lang.Object
com.fsf.news.controller.NewsControllerTest

@ExtendWith(org.mockito.junit.jupiter.MockitoExtension.class) class NewsControllerTest extends Object
Unit tests for the NewsController class.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    (package private) com.fsf.news.controller.NewsController
     
    (package private) com.fsf.news.view.html.ErrorView
     
    (package private) play.data.Form<com.fsf.news.model.form.NewsForm>
     
    (package private) play.data.FormFactory
     
    (package private) play.twirl.api.Html
     
    (package private) play.i18n.Messages
     
    (package private) play.i18n.MessagesApi
     
    (package private) play.mvc.Http.Request
     
    (package private) play.mvc.Result
     
    (package private) com.fsf.news.service.NewsService
     
    (package private) play.mvc.Http.Session
     
    (package private) com.fsf.news.view.html.SourceProfileView
     
    (package private) play.data.Form<com.fsf.news.model.form.NewsSourcesForm>
     
    (package private) com.fsf.news.service.NewsSourcesService
     
    (package private) com.fsf.news.view.html.NotilyticsView
     
    (package private) com.fsf.news.view.html.WordStatsView
     
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    (package private) void
    Tests that the error method renders the error HTML view.
    (package private) void
    Tests that the index method redirects to the NotiLytics page.
    (package private) void
    Tests that the notilytics method renders the NotiLytics HTML view with an existing session.
    (package private) void
    Tests that the notilytics method renders the NotiLytics HTML view with a new session.
    (package private) void
    Tests that the search method searches for news based on the provided form data and returns the rendered NotiLytics HTML view.
    (package private) void
    Tests that the search method throws an InvalidSessionException when no session ID is available.
    (package private) void
    Tests that the sourceByName method retrieves a source profile and renders the corresponding HTML view.
    (package private) void
    Tests that the sources method searches for sources based on the provided form data and returns the rendered NotiLytics HTML view.
    (package private) void
    Tests that the sources method throws an InvalidSessionException when no session ID is available.
    (package private) void
    Tests that the wordStats method retrieves and renders word statistics.
    (package private) void
    Tests that the wordStats method throws an InvalidSessionException when no session ID is available.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • controller

      @InjectMocks com.fsf.news.controller.NewsController controller
    • service

      @Mock com.fsf.news.service.NewsService service
    • sourcesService

      @Mock com.fsf.news.service.NewsSourcesService sourcesService
    • view

      @Mock com.fsf.news.view.html.NotilyticsView view
    • wordStatsView

      @Mock com.fsf.news.view.html.WordStatsView wordStatsView
    • sourceProfileView

      @Mock com.fsf.news.view.html.SourceProfileView sourceProfileView
    • errorView

      @Mock com.fsf.news.view.html.ErrorView errorView
    • formFactory

      @Mock play.data.FormFactory formFactory
    • form

      @Mock play.data.Form<com.fsf.news.model.form.NewsForm> form
    • sourcesForm

      @Mock play.data.Form<com.fsf.news.model.form.NewsSourcesForm> sourcesForm
    • messagesApi

      @Mock play.i18n.MessagesApi messagesApi
    • request

      @Mock play.mvc.Http.Request request
    • session

      @Mock play.mvc.Http.Session session
    • messages

      @Mock play.i18n.Messages messages
    • html

      @Mock play.twirl.api.Html html
    • result

      @Mock play.mvc.Result result
  • Constructor Details

    • NewsControllerTest

      NewsControllerTest()
  • Method Details

    • testIndex

      @Test void testIndex()
      Tests that the index method redirects to the NotiLytics page.
    • testNotilyticsExistingSession

      @Test void testNotilyticsExistingSession()
      Tests that the notilytics method renders the NotiLytics HTML view with an existing session.
    • testNotilyticsNewSession

      @Test void testNotilyticsNewSession()
      Tests that the notilytics method renders the NotiLytics HTML view with a new session.
    • testSearch

      @Test void testSearch()
      Tests that the search method searches for news based on the provided form data and returns the rendered NotiLytics HTML view.
    • testSearchInvalidSessionException

      @Test void testSearchInvalidSessionException()
      Tests that the search method throws an InvalidSessionException when no session ID is available.
    • testSources

      @Test void testSources()
      Tests that the sources method searches for sources based on the provided form data and returns the rendered NotiLytics HTML view.
    • testSourcesInvalidSessionException

      @Test void testSourcesInvalidSessionException()
      Tests that the sources method throws an InvalidSessionException when no session ID is available.
    • testWordStats

      @Test void testWordStats()
      Tests that the wordStats method retrieves and renders word statistics.
    • testWordStatsInvalidSesionException

      @Test void testWordStatsInvalidSesionException()
      Tests that the wordStats method throws an InvalidSessionException when no session ID is available.
    • testError

      @Test void testError()
      Tests that the error method renders the error HTML view.
    • testSourceByName

      @Test void testSourceByName()
      Tests that the sourceByName method retrieves a source profile and renders the corresponding HTML view.